package com.example.dao;

import com.example.entity.ClassInfo;
import com.example.entity.TeacherInfo;
import com.example.entity.XuankeInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface XuankeInfoDao extends Mapper<XuankeInfo> {

    @Select("select * from xuanke_info")
    List<XuankeInfo> selectAllClass();


    @Select("select * from xuanke_info where name like concat('%',#{name},'%')")
    List<XuankeInfo> findByNamePage(String name);

    @Select("select * from xuanke_info where name = #{name} and teacherid = #{teacherid} and studentid = #{studentid}")
    XuankeInfo find(@Param("name") String name, @Param("teacherid")Long teacherid,@Param("studentid") long studentid);


    List<XuankeInfo> findByPageCondition(@Param("teacherid") Long teacherid,@Param("studentid") Long studentid);
    @Select("select * from xuanke_info where id=#{id} ")
    XuankeInfo selectBYId(Long id);

    @Delete("DELETE FROM xuanke_info WHERE id = #{id}")
    void deleteById(Long id);
    @Update("UPDATE xuanke_info " +
            "SET name = #{name}, decription = #{decription}, zhuanyeid = #{zhuanyeid} , score = #{score}, teacherid = #{teacherid}" +
            ", kaiban = #{kaiban}, yixuan =#{yixuan}," +
            "time = #{time}, location = #{location} ,studentid= #{studentid},status= #{status}" +" "+//这个空格必须加，否则会 报错
            "WHERE id = #{id}")
    void updateById(@Param("id") long id, @Param("name")String name,
                    @Param("decription")String decription, @Param("zhuanyeid") Long zhuanyeid,
                    @Param("score") Integer score, @Param("teacherid")Long teacherid,
                    @Param("kaiban")Integer kaiban, @Param("time") String time,
                    @Param("location")String location, @Param("studentid")Long studentid,
                    @Param("status") String status, @Param("yixuan") Integer yixuan);
}
